################################################################################
## ANALYSIS SCRIPT FOR PRAGLOOK
## analyze data from the praglook experiment
##
## mcf 6/13
################################################################################

## PRELIMINARIES
rm(list = ls())
source("useful.R")
source("et_helper.R")

d <- read.csv("processed_data/praglook processed.csv")

## minor odds and ends
d <- subset(d,stimulus != "cross_white") # remove fixation cross
d$stimulus <- to.n(d$stimulus) # convert to numeric

################ PRELIMINARIES #################
## 1. Read in the orders and merge them with the data
## HINT: this will be a "merge"

order <- read.csv("info/order1.csv")



## 2. Define the target ROIs (regions of interest)

rois <- list()
rois[[1]] <- c(0,0,840,550) # left
## what are the others?
names(rois) <- c("L","R","C")

# check these
roi.image(rois)

## now: use check code assess ROIs
d$roi <- roi.check(d,rois) 

# QUESTION: what's the distribution of fixation across ROIS?



# QUESTION: how do we make a "correct" column that's TRUE if fixation is in the 
# target ROI?




## 3. Align trials to the onset of the critical word
d <- rezero.trials(d)

## 4. subsample the data so that you get smooth curves
##    I like to do this when I don't have much data so that I'm not distracted 
##    by the variation in the data, but then relax the subsampling if I have more data.
subsample.hz <- 10 # 10 hz is decent, eventually we should set to 30 or 60 hz
d$t.crit.binned <- round(d$t.crit*subsample.hz)/subsample.hz # subsample step

